from django.db import models

# Create your models here.
class BaseModel(models.Model):
    update_time=models.DateTimeField(auto_now=True)
    create_time=models.DateTimeField(auto_now_add=True)
    class Meta:
        abstract=True#该字段表示是基类用来继承的，不是创建表的

class Grade(BaseModel):
    name=models.CharField(verbose_name="班级名称",max_length=10,unique=True)
    teacher = models.CharField(verbose_name="老师", max_length=20)

    class Meta:
        db_table="grade"
        verbose_name="班级表"
        # verbose_name_plural="班级表"

class Student(BaseModel):
    name=models.CharField(max_length=50,verbose_name="真实姓名")
    qq=models.CharField(max_length=13,verbose_name="qq",unique=True)
    phone=models.CharField(max_length=11,verbose_name="手机号",unique=True)
    sex_choice=(
        (0,"女"),
        (1,"男"),
    )
    sex=models.SmallIntegerField(choices=sex_choice,verbose_name="性别")
    grade=models.ForeignKey(Grade,on_delete=models.PROTECT,verbose_name="班级")

    class Meta:
        db_table="student"
        verbose_name="学生"